package org.proxycine.gestsalles.web.beans;

import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import org.proxycine.gestsalles.model.entities.Film;
import org.proxycine.gestsalles.model.entities.GenreFilm;
import org.proxycine.gestsalles.services.FilmService;

@ManagedBean(name="modifierFilmBean")
@SessionScoped

public class ModifierFilmBean implements Serializable {
	
	private static final long serialVersionUID = 1L;
	
	private Film selectedFilm;
	private int idFilm;
	
	public String valideModification() {
		System.out.println("titre modifié : " + selectedFilm.getTitre());
		
		FilmService.getInstance().updateFilm(selectedFilm);
		
		return "listeFilms";
	}
	
	public GenreFilm[] getGenresList() {	    
	    return GenreFilm.values();
	}

	public Film getSelectedFilm() {
		return selectedFilm;
	}

	public void setSelectedFilm(Film selectedFilm) {
		this.selectedFilm = selectedFilm;
	}

	public int getIdFilm() {
		return idFilm;
	}

	public void setIdFilm(int idFilm) {
		this.idFilm = idFilm;
		this.selectedFilm = FilmService.getInstance().getFilm(idFilm);
	}
}
